package com.ag.wsq.action;
/*
 * @author 王淑其
 */
import org.apache.log4j.Logger;

import com.ag.bean.TbDuty;
import com.ag.bean.TbShiftType;
import com.ag.bean.TbWorkDay;
import com.ag.common.BaseAction;
import com.ag.wsq.service.impl.SchedBaseServiceImpl;

public class AddDutyAction extends BaseAction {

	private static final Logger logger = Logger.getLogger(AddDutyAction.class);
	private SchedBaseServiceImpl schedBaseServiceImpl;	
	private String wdId1;
	private String psId1;
	private String duId1;
	private String duPhone;	
	private String ajaxRST="0";
	
	/*
	 * 保存岗位
	 */
	public String saveDuty()throws Exception{
		TbWorkDay wDay1 = schedBaseServiceImpl.findWDayById(wdId1);
		TbShiftType sType1 = schedBaseServiceImpl.findSTypeById(psId1);
		logger.info("输出wDay1---"+wDay1);
		logger.info("输出sType1----"+sType1);
		logger.info("输出wdId1---"+wdId1);
		logger.info("输出psId1----"+psId1);
		if (wDay1!=null && sType1!=null) {
			if (duId1!=null && duId1.length()>0) {
				TbDuty duty = new TbDuty();
				duty.setDuId(duId1);
				duty.setTbWorkDay(wDay1);
				duty.setTbShiftType(sType1);				
				duty.setDuPhone(duPhone);
				
	logger.info("---------------------save start---------");
	logger.info("---------------------save start---------");
				schedBaseServiceImpl.saveOrUpdateDuty(duty);
				
				this.ajaxRST="1";
				System.out.println("save duty ok!");
			} else {
				System.out.println("can not to be null");
			}
			
		} else {
			System.out.println("shiftType or workDay cannot be null!");
		}
		
		return "saveDutyOK";
	}

	public SchedBaseServiceImpl getSchedBaseServiceImpl() {
		return schedBaseServiceImpl;
	}

	public void setSchedBaseServiceImpl(SchedBaseServiceImpl schedBaseServiceImpl) {
		this.schedBaseServiceImpl = schedBaseServiceImpl;
	}

	public String getWdId1() {
		return wdId1;
	}

	public void setWdId1(String wdId1) {
		this.wdId1 = wdId1;
	}

	public String getPsId1() {
		return psId1;
	}

	public void setPsId1(String psId1) {
		this.psId1 = psId1;
	}

	public String getDuId1() {
		return duId1;
	}

	public void setDuId1(String duId1) {
		this.duId1 = duId1;
	}

	public String getDuPhone() {
		return duPhone;
	}

	public void setDuPhone(String duPhone) {
		this.duPhone = duPhone;
	}

	public String getAjaxRST() {
		return ajaxRST;
	}

	public void setAjaxRST(String ajaxRST) {
		this.ajaxRST = ajaxRST;
	}
	
	
}
